<?php


/* @var $this StatusController */
/* @var $model Status */
//
$this->breadcrumbs = array (
	yii :: t('base', 'Potential Customer') => array (
		'index'
	),
	$modelcustomers->potential_customers_id,

	
);
?>
<?php 
$attachmentsarr=array("0"=>"ADSL+宽带明细","1"=>"产品套餐明细");
?>
<script type="text/javascript">
<!--发送邮件弹出框-->
function sendNewLetter()
{
	var email=$('#email1').val();
			$('#receiver').val(email);
				$.fancybox.open({
					href : '#inline1',
					type : 'inline',
					maxWidth	: 500,
					maxHeight	: 380,
					fitToView	: false,
					width		: '500',
					height		: '380',
					autoSize	: false,
					openEffect	: 'none',
					closeBtn	: true,//正式发布时请将true,改为false,不显示关闭按钮
					closeClick	: false,
					helpers : {
						overlay : null,
					}
			});
}
<!--发送短信-->
function sendSms()
{
	var smscontent=$('#smscontent').val();
	var mobile=<?php echo $modelcustomers->mobile;?>;
	   $.post("<?php echo Yii::app()->createUrl('status/sendSms'); ?>",{'smscontent':smscontent,'mobile':mobile}, 
            function (data) {
                alert(data);
                $('#smscontent').val("");                             
            });
}
</script>
<?php


/* @var $this StatusController */
/* @var $model Status */
/* @var $form CActiveForm */
?>

<div class="form">

<?php


$form = $this->beginWidget('CActiveForm', array (
	'id' => 'status-form',
	'enableAjaxValidation' => false,

	
));
?>

	<p class="note"><?php echo Yii::t('base','Fields with <span class="required">*</span> are required.');?></p>

	<?php echo $form->errorSummary($model); ?>
	<div class="row">
		<?php echo $form->hiddenField($model,'customer_id',array('value'=>$modelcustomers->potential_customers_id)); ?>
		<?php echo $form->error($model,'customer_id'); ?>
	</div>
	<div class="row">
		<?php echo $form->hiddenField($model,'last_called_date_and_time',array('value'=>$model->last_called_date_and_time)); ?>
		<?php echo $form->error($model,'last_called_date_and_time'); ?>
	</div>
		<div class="row">
		<?php echo $form->hiddenField($model,'campaign_id',array('value'=>$model->campaign_id)); ?>
		<?php echo $form->error($model,'campaign_id'); ?>
	</div>	
		<label><?php echo Yii::t('base','Campaign')?>：</label><input type="text" value="<?php echo Campaign::model()->getCampaignName($model->campaign_id);?>" id="campaignName" readonly="true"/>
		<label><?php echo Yii::t('base','Campaign Script')?>：</label><textarea colws='20' rows='5' readonly="true"><?php echo Campaign::model()->getCampaignScript($model->campaign_id);?></textarea>
	<label><?php echo Yii::t('base','PotentialCustomersListName')?>：</label><input type="text" value="<?php echo PotentialCustomersList::model()->getPotentialCustomerListName($modelcustomers->potential_customers_id);?>" readonly="true"/>
	<div class="row">
		<?php echo $form->hiddenField($model,'agent_id',array('value'=>Yii::app()->user->id)); ?>
		<?php echo $form->error($model,'agent_id'); ?>
	<label><?php echo Yii::t('base','FirstName')?>：</label><input type="text" value="<?php echo $modelcustomers->first_name;?>" readonly="true"/>
	<label><?php echo Yii::t('base','LastName')?>：</label><input type="text" value="<?php echo $modelcustomers->last_name;?>" readonly="true"/>
	<label><?php echo Yii::t('base','Phone Number')?>：</label><a href="tel:<?php echo $modelcustomers->mobile;?>"><?php echo $modelcustomers->mobile;?></a>
	<textarea rows="8" cols="15" wrap="off" id="smscontent"></textarea>
	<input type="button" value="<?php echo Yii::t('base','Send SMS');?>" id="sendsms" onclick="sendSms();"/>
	<label><?php echo Yii::t('base','Choose One Feedback')?>:</label>
	<input type="radio" name="status" value="1" id="other1">No Answer<br/>
	<input type="radio" name="status" value="2" id="other2">Busy or Not Available<br/>
	<input type="radio" name="status" value="3" id="other3">Invalid Number<br/>
	<input type="radio" name="status" value="4" id="other4">Do not call again<br/>
	<input type="radio" name="status" value="5" id="other5">No interest<br/>
	<input type="radio" name="status" value="6" id="qualified">Qualified lead<br/>
	<input type="radio" name="status" value="7" id="won">Won
	</div>
	
	

<div style="display: none;" id="divform1">
    <!-- 这里是表单1,当用户输入邀请码后显示的表单 -->
      <label><?php echo Yii::t('base','Qualified Lead');?></label>
      <p><span><?php echo Yii::t('base','follow up' );?>: </span>
        <input type="text" id="follow_up1" name="follow_up" size="20" value="<?php echo $model->follow_up=='0000-00-00 00:00:00'?date("Y-m-d H:i:s",strtotime("+7 days")):$model->follow_up;?>" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" " style="width:245px;" /> 
       <a id="google-button" target="_blank" style="display: none;"><img src="//www.google.com/calendar/images/ext/gc_button1.gif" border=0></a>
        </p>
      <p><span><?php echo Yii::t('base','sign up date');?> : </span>
        <input type="text" id="sign_up_date1" name="sign_up_date1" size="20" value="<?php echo $model->sign_up_date=='0000-00-00 00:00:00'?date("Y-m-d H:i:s",strtotime("+7 days")):$model->sign_up_date;?>" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" " style="width:245px;" />
      </p>
      <p><span><?php echo Yii::t('base','Contract Expire date')?> : </span>
        <input type="text" id="contract_expire_date1" name="contract_expire_date1" size="24"  value="<?php echo $model->contract_expire_date=='0000-00-00 00:00:00'?date("Y-m-d H:i:s",strtotime("+7 days")):$model->contract_expire_date;?>" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" " style="width:245px;" />
      </p>
      <p><span> <?php echo Yii::t('base','Package');?>: </span>
        <input type="text" id="package1" name="package1" size="24" style="width:245px;" />
      </p>
  </div>
  
  
  <div style="display: none;" id="divform2">
    <!-- 这里是表单1,当用户输入邀请码后显示的表单 -->
      <label><?php echo Yii::t('base','Won');?></label>
      <p><span><?php echo Yii::t('base','sign up date');?> : </span>
        <input type="text" id="sign_up_date1" name="sign_up_date" size="20"  value="<?php echo $model->sign_up_date=='0000-00-00 00:00:00'?date("Y-m-d H:i:s",strtotime("+7 days")):$model->sign_up_date;?>" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" " style="width:245px;" />
      </p>
      <p><span><?php echo Yii::t('base','Contract Expire date');?> : </span>
        <input type="text" id="contract_expire_date1" name="contract_expire_date" size="24" value="<?php echo $model->contract_expire_date=='0000-00-00 00:00:00'?date("Y-m-d H:i:s",strtotime("+7 days")):$model->contract_expire_date;?>" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" " style="width:245px;" />
      </p>
      <p><span> <?php echo Yii::t('base','Package');?>: </span>
        <input type="text" id="package1" name="package" size="24" style="width:245px;" />
      </p>    
  </div>
  
	<div class="row">
	 <label><?php echo Yii::t('base','Update Client Information');?>：</label>
      <p><span><?php echo Yii::t('base','FirstName');?>： </span>
        <input type="text" id="frist_name1" name="first_name" size="24" style="width:245px;" value="<?php echo $modelcustomers->first_name;?>" />
      </p>

		<p><span><?php echo Yii::t('base','LastName');?>： </span>
        <input type="text" id="last_name1" name="last_name" size="24" style="width:245px;" value="<?php echo $modelcustomers->last_name;?>" />
      </p>
       <div class="row">
      	<?php

?>


      	<p><span><?php echo Yii::t('base','Title');?>： </span>
		<?php echo $form->dropDownList($modelcustomers,'gender',array('Mr'=>'Mr','Mrs'=>'Mrs','Ms'=>'Ms','Miss'=>'Miss','Dr'=>'Dr',''=>'--')); ?>
		<?php echo $form->error($modelcustomers,'gender'); ?>    
     </div>
      <p>
        <input type="hidden" id="mobile1" name="mobile" size="24" style="width:245px;"  value="<?php echo $modelcustomers->mobile;?>" />
      </p>
      <p><span><?php echo  Yii::t('base','Email');?></span>
        <input type="text" id="email1" name="email" size="24" style="width:245px;" value="<?php echo $modelcustomers->email;?>" />
    
     <input type="button" value="<?php echo Yii::t('base','Send News Letter');?>" id="sendletter" onclick="sendNewLetter();"/>
     
      </p>
      <p><span><?php echo  Yii::t('base','Address');?></span>
        <input type="text" id="address1" name="address" size="24" style="width:245px;" value="<?php echo $modelcustomers->address;?>" />
      </p>
      <p><span><?php echo  Yii::t('base','Post Code');?> </span>
        <input type="text" id="post_code1" name="post_code" size="24" style="width:245px;" value="<?php echo $modelcustomers->post_code;?>" />
      </p>
	</div>
		<div class="row">
	<?php echo $form->labelEx($model,'notes'); ?>
		<?php echo $form->textArea($model,'notes');?>
		<?php echo $form->error($model,'notes'); ?>
</div>

<!-- 把在prepaid select里收集到的信息都显示出来，包括地址。 有一点比较特殊的是，要求显示出来这个客户是否中过奖-->
	<div>
	<div class="row">
	<p><span><?php echo Yii::t('base','Partners');?> : </span>
        <?php echo $surveyuser->partner_id;?>
      </p>
      </div>     
      	<div class="row">
	<p><span><?php echo Yii::t('base','Title');?> : </span>
       <?php echo $surveyuser->activety_code;?>
      </p>
      </div>
      <div class="row">
	<p><span><?php echo Yii::t('base','Zipcode');?> : </span>
       <?php echo $surveyuser->zipcode;?>
      </p>
      </div>
   <div class="row">
	<p><span><?php echo Yii::t('base','Job');?> : </span>
       <?php echo $surveyuser->job;?>
      </p>					
      </div>
         <div class="row">
	<p><span><?php echo Yii::t('base','Favo');?> : </span>
     <?php echo $surveyuser->favo;?>
      </p>					
      </div>
         <div class="row">
	<p><span><?php echo Yii::t('base','Identity ID');?> : </span>
        <?php echo $surveyuser->Identity_id;?>
      </p>					
      </div>
         <div class="row">
	<p><span><?php echo Yii::t('base','Award Address');?> : </span>
        <?php echo $surveyuser->award_address_id;?>
      </p>					
      </div>
         <div class="row">
	<p><span><?php echo Yii::t('base','Winning Status');?> : </span>
        <?php echo SurveyUser::model()->winningStatus($surveyuser->winning_status);?>
      </p>					
      </div>
         <div class="row">
	<p><span><?php echo Yii::t('base','SMS Status');?> : </span>
        <?php echo $surveyuser->sms_status;?>
      </p>					
      </div>
         <div class="row">
	<p><span><?php echo Yii::t('base','Birthday');?> : </span>
       <?php echo $surveyuser->birthday;?>
      </p>					
      </div>
         <div class="row">
	<p><span><?php echo Yii::t('base','Full Street Address');?> : </span>
       <?php echo $surveyuser->full_street_address;?>
      </p>					
      </div>
         <div class="row">
	<p><span><?php echo Yii::t('base','Suburb');?> : </span>
       <?php echo $surveyuser->suburb;?>
      </p>					
      </div>
         <div class="row">
	<p><span><?php echo Yii::t('base','State');?> : </span>
        <?php echo $surveyuser->state;?>
      </p>					
      </div>
         <div class="row">
	<p><span><?php echo Yii::t('base','ID Type');?> : </span>
        <?php echo $surveyuser->id_type;?>
      </p>					
      </div>
         <div class="row">
	<p><span><?php echo Yii::t('base','ID Number');?> : </span>
        <?php echo $surveyuser->id_number;?>
      </p>					
      </div>
         <div class="row">
	<p><span><?php echo Yii::t('base','IP');?> : </span>
        <?php echo $surveyuser->IP;?>
      </p>					
      </div>
	</div>


	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? Yii::t('base','Submit and Next>>'): 'Save',array('id'=>'next')); ?>
	</div>
	
		<div class="row buttons">
		<?php echo CHtml::submitButton('submit',array('name'=>'stop','value'=>Yii::t('base','Submit and Stop >>'),'id'=>'stop')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->
  <div id="inline1" font:16px/45px '微软雅黑', Arial, Helvetica, sans-serif; color:#333; background:#fff;" style="display: none;"> 
 <h1 style="font:24px/40px '微软雅黑', Arial, Helvetica, sans-serif; background:rgb(23, 177, 249) ; margin:0; color:#fff; padding:10px 30px;">发送产品资料</h1>
  <form method="post" id="form1" style=" padding:20px 80px 0;">
	<p><span>收件人:</span>
	<input type="text" value="" id="receiver"/>	
	</p>
	<p><span>选择邮件:</span>
	<select name="templet" id="templet">
	<option value="1">ADSL+宽带</option>
	<option value="2">产品套餐</option>
</select>
	</p>
		<p><span>选择附件:</span>
		<?php 
		for($i=0;$i<count($attachmentsarr);$i++)
		{
		?>
		<input type="checkbox" class="checkbox" id="attachments" name="attachments" value="<?php echo array_search($attachmentsarr[$i],$attachmentsarr);?>"/><?php echo $attachmentsarr[$i];?>
		<?php 	
		}
		?>
	</p>
	    <p style="align:center">
        <input type="button" id="send" value="发送" style="font-size:20px !important; width:100%;"/>
      </p>
</form>
  </div>
<?php


Yii :: app()->clientScript->registerScript('search', "
		$('#qualified').click(function(){
		$('#divform2').hide();
		$('#divform1').show();
		});
		");
Yii :: app()->clientScript->registerScript('search1', "
		$('#won').click(function(){
		$('#divform1').hide();
			$('#divform2').show();
		});
		");

Yii :: app()->clientScript->registerScript('search2', "
		$('#other1').click(function(){
		$('#divform1').hide();
			$('#divform2').hide();
		});
		
		$('#other2').click(function(){
		$('#divform1').hide();
			$('#divform2').hide();
		});
		
		$('#other3').click(function(){
		$('#divform1').hide();
			$('#divform2').hide();
		});
		
		$('#other4').click(function(){
		$('#divform1').hide();
			$('#divform2').hide();
		});
		
		$('#other5').click(function(){
		$('#divform1').hide();
			$('#divform2').hide();
		});
		");
Yii :: app()->clientScript->registerScript('search3', "
		$('#follow_up1').blur(function(){
			if($('#follow_up1').val()!=''){
				var follow_up1=	$('#follow_up1').val();
				var followone=follow_up1.substring(0,4);
				var followtwo=follow_up1.substring(0,4);
				var follow1=follow_up1.substring(5,7);
				var follow2=follow_up1.substring(8,10);
				var follow3=parseInt(follow_up1.substring(8,10))+parseInt('1');			
				followone+=follow1;
				followone+=follow2;
				followtwo+=follow1;	
				followtwo+=follow3;			
				var campaignName=$('#campaignName').val();
				campaignName+=' ';	
				campaignName+='$modelcustomers->mobile';
				campaignName+=' ';
				campaignName+='Followup';
				var details='姓名：';
				details+=$('#frist_name1').val();
				details+=' ';	
				details+=$('#last_name1').val();
				details+='电话：';		
				details+='$modelcustomers->mobile';		
				details+='邮政编码：';
				details+='$modelcustomers->post_code';		
				details+='地址：';		
				details+=$('#address1').val();		
				details+='邮件：';
				details+=$('#email1').val();
				details+='所在的销售活动：';	
				details+=$('#campaignName').val(); 	
						
						
				var link='http://www.google.com/calendar/event?action=TEMPLATE&text='+campaignName+'&dates='+followone+'/'+followtwo+'&details='+details+'&location=&add=aaron.zhao@webnova.net.au&trp=false&sprop=&sprop=name:';
				$('#google-button').attr('href',link);
				$('#google-button').show();
			}else{
				alert('" . Yii :: t('base', 'please enter the follow up date.') . "');
				$('#follow_up1').focus();
			}
		});
		");
//$(':radio:checked').length被选中的长度只有1,!flag是等于(==)true的时候就进下一个判断语句
Yii :: app()->clientScript->registerScript('search4', "
		$('#next').click(function(){
		var flag=0;
        for(i=0;i<$(':radio:checked').length;i++)
        if($(':radio:checked').get(0).checked=true){
            flag=1;
            break;
        }
        if(!flag){
            alert('" . Yii :: t('base', 'please enter the choose one feedback.') . "');
            return false;
        }
		});
		$('#stop').click(function(){
		var flag=0;
        for(i=0;i<$(':radio:checked').length;i++)
        if($(':radio:checked').get(0).checked=true){
            flag=1;
            break;
        }
        if(!flag){
            alert('" . Yii :: t('base', 'please enter the choose one feedback.') . "');
            return false;
        }
		});
		");
		//checked.push($(this).val());把复选框选中的值加入到数组里
	Yii :: app()->clientScript->registerScript('search5', "
			$('#send').click(function()
		{
			var email=$('#receiver').val();
			var templet=$('#templet option:selected').val();
			var checked=new Array();
		$('input:checkbox[name=attachments]:checked').each(function(){
		checked.push($(this).val());	
		});
			var str='';
			str=checked.join('|');
	   		$.ajax({
					type: 'POST',
					url:'".Yii::app()->createUrl("/status/sendNewLetter/")."',
					data: {'email_to': email,'templet':templet,'attachments':str},
					success: function(data){
					alert(data);
					}
					
				});
			});
		");
?>